﻿#region Copyright Notice
// This file is part of GestionPedago.
// <description>
// Copyright (C) 2012 ENI Ecole Informatique
// 
// GestionPedago is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// <program> is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
#endregion

using System;
using System.Collections.Generic;
using System.Text;
using GestionPedago.EntityContext;
using GestionPedago.Services.Framework;
using GestionPedago.Services.ES.Modele;

namespace GestionPedago.Services.Mapping
{
    /// <summary>
    /// Classe de mapping Entity<->ES de l'objet ProfilStagiaire
    /// </summary>
    public class ProfilStagiaireMappeur : IMappeur<ProfilStagiaire, ProfilStagiaireES>
    {
        /// <summary>
        /// Constructeur
        /// </summary>
        public ProfilStagiaireMappeur() { }

        /// <summary>
        /// Mapping Entity -> ES
        /// </summary>
        /// <param name="entity">L'entity à mapper</param>
        /// <returns>L'ES obtenu</returns>
        public ProfilStagiaireES Entity2ES(ProfilStagiaire entity)
        {
            ProfilStagiaireES retour = new ProfilStagiaireES();
            retour.CodeStagiaire = entity.CodeStagiaire;
            retour.DateCreation = entity.DateCreation;
            retour.DateModification = entity.DateModification;
            retour.CodeContactEni = entity.CodeContactEni;
            retour.TagEtude = entity.TagEtude;
            retour.TagExperience = entity.TagExperience;
            retour.TagTechnique = entity.TagTechnique;
            retour.TagDivers = entity.TagDivers;
            retour.Observation = entity.Observation;
            retour.CodeStatut = entity.CodeStatut;
            retour.CodeAllocation = entity.CodeAllocation;
            retour.EstEnRecherche = entity.EstEnRecherche;
            retour.DateDisponibilite = entity.DateDisponibilite;
            //TODO implémenter mapping Entity<->ES manuellement ! : ContactENI
            //TODO implémenter mapping Entity<->ES manuellement ! : Stagiaire
            return retour;
        }

        /// <summary>
        /// Mapping ES -> Entity
        /// </summary>
        /// <param name="es">L'ES à mapper</param>
        /// <returns>L'entity obtenu</returns>
        public ProfilStagiaire ES2Entity(ProfilStagiaireES es)
        {
            ProfilStagiaire retour = new ProfilStagiaire();
            retour.CodeStagiaire = es.CodeStagiaire;
            retour.DateCreation = es.DateCreation;
            retour.DateModification = es.DateModification;
            retour.CodeContactEni = es.CodeContactEni;
            retour.TagEtude = es.TagEtude;
            retour.TagExperience = es.TagExperience;
            retour.TagTechnique = es.TagTechnique;
            retour.TagDivers = es.TagDivers;
            retour.Observation = es.Observation;
            retour.CodeStatut = es.CodeStatut;
            retour.CodeAllocation = es.CodeAllocation;
            retour.EstEnRecherche = es.EstEnRecherche;
            retour.DateDisponibilite = es.DateDisponibilite;
            //TODO implémenter mapping Entity<->ES manuellement ! : ContactENI
            //TODO implémenter mapping Entity<->ES manuellement ! : Stagiaire
            if (!EntityStateChecker.IsDetached(retour))
            {
                EntityConnection.GetContext().ProfilStagiaire.ApplyCurrentValues(retour);
            }
            else
            {
                EntityConnection.GetContext().ProfilStagiaire.Attach(retour);
            }
            return retour;
        }
    }
}
